


<template>
  <div class="errorpage" ref="bgstar" >
      <img :src="Img" alt="" class="myimg">
      <div class="down" @click="gotopage('/ms')" >剩余 {{total}} S</div>
      <span class="spandot" v-for="(item,index) in spanList" :key="index" :style="item" ></span>
  </div>
</template>

<script>
import Img from '@/assets/images/404.png'
var timer = null;
export default {
    data(){
      return {
        spanList:[],
        Img,
        total:5,
      }
    },
    methods:{
      getSpanList(){
        let width = this.$refs.bgstar.clientWidth
        let height = this.$refs.bgstar.clientHeight
        for(let i = 0; i<520;i++){
          var left = width * Math.random()
          var top = height * Math.random()
          var scaler = Math.random() * 1.5;
          var rate = Math.random() * 2.5;
          var opacity = Math.random()

          this.spanList.push({
            left:left+'px',
            top:top+'px',
            animationDelay:rate+'s',
            transform:`scale(${scaler})`,
            background:`rgba(255,255,255,${opacity})`
          })
        }
      },
      timeDown(){
       timer = setInterval(()=>{
          if(this.total > 0){
            this.total--;

          }else{
            clearInterval(timer)
            timer = null;
            this.$router.push("/ms")
          }
        },1000)
      }
    },
    mounted(){
      this.getSpanList()
      this.timeDown()
    },
    destroyed(){
      clearInterval(timer);
    }
}
</script>


<style lang="scss" scoped>
.errorpage{
  width:100%;
  height:100%;
  background: #000;
  position: relative;
  padding:0 !important;
  overflow: hidden;
  .down{
    position:absolute;
    left:20px;
    top:20px;
    border:1px solid #fff;
    color:#fff;
    width:70px;
    height:30px;
    border-radius:10px;
    text-align:center;
    line-height:30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    .van-count-down{
        color:#fff;
        margin-right:2px;
        font-size: 12px;
    }
  }
  .dao{
    position: absolute;
    top:20px;
    right:20px;
    ::v-deep .van-circle__text{
        color:#fff !important;
        font-size: 12px !important;
    }
  }
  .myimg{
    width:270px;
    height:270px;
    position: absolute;
    top:0;
    right:0;
    left:0;
    bottom:0;
    margin:auto;
    z-index:10;
  }
  .spandot{
    position: absolute;
    z-index: 100;
    width: 4px;
    height:4px;
    border-radius: 50%;
    animation: flash 3s infinite alternate;
  }
   @keyframes flash {
        from{
            opacity: 0;
        }
        to{
            opacity: 0.5;
        }
    }
}
</style>
